package test.test6_27;

/*
提供以下两个动物需要描述，请用你的知识来编写代码
 猫：姓名，年龄，颜色，可以叫，可以抓老鼠
 狗：姓名，年龄，性别，可以叫，可以看门
 分析这个案例，设计出合适的继承体系。
 */
public class Demo01 {
    public static void main(String[] args) {
        Cat c = new Cat("小红",2,"red");
        c.catchTheMouse();
        c.call();

        Dog d = new Dog("小黄",4,"black");
        d.lookAfterTheHouse();
        d.call();
    }
}

class Animal {
    String name;
    int age;
    String color;

    public Animal() {
    }

    public Animal(String name, int age, String color) {
        this.name = name;
        this.age = age;
        this.color = color;
    }

    public void call() {
        System.out.println(name + "...叫");
    }


}

class Cat extends Animal {
    public Cat() {
        super();
    }

    public Cat(String name, int age, String red) {
        super(name,age,red);
    }

    @Override
    public void call() {
        System.out.println("猫叫");
    }

    public void catchTheMouse() {
        System.out.println(name + "...抓老鼠，年龄："+age+",颜色："+color);
    }

}

class Dog extends Animal {
    public Dog() {
        super();
    }

    public Dog(String name, int age, String color) {
        super(name, age, color);
    }


    public void lookAfterTheHouse() {
        System.out.println(name + "...看门,年龄："+age+"，颜色："+color);
    }

    @Override
    public void call() {
        System.out.println("狗叫");
    }
}
